package dao

import (
	"fmt"
	"server_cluster/http/model"
)

func (d *Dao) QueryManagerByUsername(username string) (*model.DbGmAccount, error) {
	account := new(model.DbGmAccount)
	err := d.db.Where("name = ?", username).First(account).Error
	fmt.Println(account)
	if err != nil {
		return nil, err
	}
	return account, nil
}

func (d *Dao) UpdateManagerToken(account *model.DbGmAccount, token string) error {
	err := d.db.Model(&model.DbGmAccount{}).
		Where("id = ?", account.Id).
		Update("token", token).Error
	fmt.Print(account)
	if err != nil {
		return err
	}
	return nil
}
